﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EqualitySample
{
    public class PointEqualityComparer : EqualityComparer<Point>
    {
        public override bool Equals(Point x, Point y)
        {
            if (x == null && y == null)
            {
                return true;
            }
            else if (x == null || y == null)
            {
                return false;
            }
            else
            {
                return x.X == y.X && x.Y == y.Y;
            }
        }

        public override int GetHashCode(Point obj)
        {
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return (17 * 23 + obj.X.GetHashCode()) * 23 + obj.Y.GetHashCode();
            }
        }
    }
}
